//
//  Mine_KanboxViewController.m
//  fxxiaoke
//
//  Created by 鞠超 on 2016/10/13.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Mine_KanboxViewController.h"

#import "Mine_KanboxTableViewCell.h"
#import "Kanbox_TrendsViewController.h"
#import "KCompany_DocumentViewController.h"
#import "KCompany_PersonalViewController.h"
#import "KCompany_SharingViewController.h"

@interface Mine_KanboxViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView * tableView;

@property (nonatomic, strong) UIView * view_Head;

@end

@implementation Mine_KanboxViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void )p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    
    _lblTitle.text = @"XX网盘";
    _topView.backgroundColor = navi_bar_bg_color;
    
    //左返回
    UIImageView * image_LeftRetrun = [[UIImageView alloc] initWithFrame:CGRectMake(11, 31.5, 25, 25)];
    image_LeftRetrun.userInteractionEnabled = YES;
    image_LeftRetrun.image = [UIImage imageNamed:@"Left-return.png"];
    [_topView addSubview:image_LeftRetrun];
    
    UILabel * lbl_return = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_LeftRetrun.frame) - 6, 35, 35, 15)];
    lbl_return.text = @"我";
    lbl_return.textColor = [UIColor whiteColor];
    lbl_return.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:lbl_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 22, 60, 40);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64) style:(UITableViewStylePlain)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    //头视图
    [self p_headView];
    self.tableView.tableHeaderView = self.view_Head;
    self.tableView.tableFooterView = [[UIView alloc] init];
    [self.view addSubview:self.tableView];
    
    //注册
    [self.tableView registerClass:[Mine_KanboxTableViewCell class] forCellReuseIdentifier:@"cell_Kanbox"];
}

#pragma mark - tableview代理
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70.0f;
}

- (UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    Mine_KanboxTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell_Kanbox" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    switch (indexPath.row)
    {
        case 0:
        {
            cell.name.text = @"公司文件";
        }
            break;
        case 1:
        {
            cell.name.text = @"个人文件";
        }
            break;
        case 2:
        {
            cell.name.text = @"收到的共享";
        }
            break;
            
        default:
            break;
    }
    
    return cell;
}

- (void )tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row)
    {
        case 0:
        {
//            NSLog(@"公司文件");
            KCompany_DocumentViewController * kCompany_DocumentViewController = [[KCompany_DocumentViewController alloc] init];
            
            [self presentViewController:kCompany_DocumentViewController animated:YES completion:^{
            }];
        }
            break;
        case 1:
        {
//            NSLog(@"个人文件");
            KCompany_PersonalViewController * kCompany_PersonalViewController = [[KCompany_PersonalViewController alloc] init];
            
            [self presentViewController:kCompany_PersonalViewController animated:YES completion:^{
            }];
        }
            break;
        case 2:
        {
//            NSLog(@"收到的共享");
            
            KCompany_SharingViewController * kCompany_SharingViewController = [[KCompany_SharingViewController alloc] init];
            
            [self presentViewController:kCompany_SharingViewController animated:YES completion:^{
            }];
        }
            break;
            
        default:
            break;
    }
}

#pragma mark - 头视图
- (void )p_headView
{
    self.view_Head = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    self.view_Head.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    //
    UIView * view_bg = [[UIView alloc] initWithFrame:CGRectMake(0, - 1000, SCREEN_WIDTH, 1000)];
    view_bg.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view_Head addSubview:view_bg];
    
    //
    UIView * view_White = [[UIView alloc] initWithFrame:CGRectMake(0, 15, SCREEN_WIDTH, 50)];
    view_White.backgroundColor = [UIColor whiteColor];
    [self.view_Head addSubview:view_White];
    
    UIImageView * image_Kanbox = [[UIImageView alloc] initWithFrame:CGRectMake(20, 12.5, 25, 25)];
    image_Kanbox.layer.masksToBounds = YES;
    image_Kanbox.image = [UIImage imageNamed:@"image_Kanbox.png"];
    [view_White addSubview:image_Kanbox];
    
    UILabel * lbl_Kanbox = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_Kanbox.frame) + 15, 15, 100, 20)];
    lbl_Kanbox.text = @"网盘动态";
    [view_White addSubview:lbl_Kanbox];
    
    UIImageView * image_return = [[UIImageView alloc] init];
    image_return.frame = CGRectMake(SCREEN_WIDTH - 15 - 20, 15, 20, 20);
    image_return.image = [UIImage imageNamed:@"rigth-return.png"];
    [view_White addSubview:image_return];
    
    UIButton * btn_White = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn_White.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
    [view_White addSubview:btn_White];
    [btn_White addTarget:self action:@selector(btn_WhiteAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

#pragma mark - 点击网盘动态
- (void )btn_WhiteAction:(UIButton *)sender
{
//    NSLog(@"点击网盘动态");
    
    Kanbox_TrendsViewController * kanbox_TrendsViewController = [[Kanbox_TrendsViewController alloc] init];
    [self showViewController:kanbox_TrendsViewController sender:nil];
}

@end
